package cn.hss.io.output;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**字节输出流
 * @author 作者：HeShaoShuai
 * @Email 邮箱：2569819541@qq.com
 * @Date 日期：2023/4/25 16:36
 * @Package 包名：cn.hss.io.output
 * @Project 项目名：JavaSE
 * @Version 1.0
 */
public class FileOutputStreamWrite {
	public static void main(String[] args) {
		FileOutputStream fos=null;
		try {
			fos =
					new FileOutputStream("fos.txt");
			//字符串转换为字节数组
			byte[] bytes = "Java程序员".getBytes();
			//写出字节数组
			fos.write(bytes);
			System.out.println("写入完毕！");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException ioe){
			ioe.printStackTrace();
		}finally {
			//关闭资源
			if (fos != null) {
				try {
					fos.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
